package com.wn.naturalbiorhythms.bean;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wn.naturalbiorhythms.R;

public class NaturalBirthdayAdapter extends BaseAdapter{
	
	public static final String key_title = "item_title";
	public static final String key_content = "item_content";

	private LayoutInflater inf;
	private List<Map<String,Object>> data;
	
	public NaturalBirthdayAdapter(Context c,List<Map<String,Object>> data){
		inf = LayoutInflater.from(c);
		this.data = data;
	}
	
	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void clear(){
		this.data.clear();
	}
	
	public boolean add(Map<String,Object> object){
		return this.data.add(object);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Map<String,Object> map = data.get(position);   
		
		View view = inf.inflate(R.layout.setting_item, null);
		TextView title = (TextView)view.findViewById(R.id.textView1_bs_title);
		TextView ct = (TextView)view.findViewById(R.id.textView2_bs_context);
		title.setText(map.get(key_title).toString());
		ct.setText(map.get(key_content).toString());
		
        return view;  
	}

}
